 <#setting time_zone="${timeZone}" >
<link href="${rc.getContextPath()}/manage/css/dwzCustomCss/dwz.custom.css?v=${ver}" rel="stylesheet" type="text/css">
<form method="post" action="${rc.getContextPath()}/manage/org/saveOrg" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
    <div class="pageContent" style="padding-left: 10px">
    
            <input type="hidden" name="navTabId" value="${navTabId!''}"> <input type="hidden" name="id" value="<#if (org.organizationCode)??>${org.organizationCode!''}</#if>">
            <input type="hidden" id="user" name="user" value="${user!''}"> 
            <div class="tabs" currentIndex="0" eventType="click" style="width: 100%">
                <div class="tabsHeader">
                    <div class="tabsHeaderContent">
                        <ul>
                            <li><a href="javascript:;"><span><@label key="detail.C">详情</@label></span> </a></li>
                            <li><a href="javascript:;"><span><@label key="user.C">用户</@label></span> </a></li>
                        </ul>
                    </div>
                </div>
                <div class="tabsContent" layoutH="320" style="padding: 0;">
                    <div>
                        <div class="pageFormContent">
                        <fieldset>
                            <dl class="nowrap">
                                <dt><@label key="organizationCode.C,colon">组织编号：</@label></dt>
                                <dd>
                                    <input name="organizationCode" value="<#if (org.organizationCode)??>${org.organizationCode!''}</#if>" size="32" type="text" maxlength="40" class="required  alphanumeric toUp"<#if
                                    (org.organizationCode)??> readonly="readonly"<#else> remote="${rc.getContextPath()}/manage/org/validateOrgCode"</#if> warn="<@label key="orgCodeExist.M">组织编号已经存在</@label>"/>
                                </dd>
                            </dl>
                            <dl class="nowrap">
                                <dt><@label key="organizationText.C,colon">组织描述：</@label></dt>
                                <dd>
                                    <input name="organizationText" value="<#if (org.organizationText)??>${org.organizationText!''}</#if>" size="64" type="text" maxlength="60" class="required" />
                                </dd>
                            </dl>
                            <dl class="nowrap">
                                <dt><@label key="parentOrganizationCode.C,colon">上级组织：</@label></dt>
                                <dd>
                                    <input readonly="readonly" name="parentOrganizationCode" value="<#if (org.parentOrganizationCode)??>${org.parentOrganizationCode!''}</#if>" size="32" type="text" maxlength="255" /> <input
                                        readonly="readonly" style="margin-left: 10px;" name="parentOrganizationText" value="<#if (org.parentOrganizationText)??>${org.parentOrganizationText!''}</#if>" size="32" type="text"
                                        maxlength="255" />
                                </dd>
                            </dl>
                            <dl class="nowrap">
                                <dt>&nbsp;</dt>
                                <dd>
                                    <label style="text-align: left;"><input type="checkbox" name="lockFlag" value="1"<#if (org.lockFlag)?? && (org.lockFlag == 1)> checked="true"</#if>><@label key="lock.C">锁定</@label></label>
                                </dd>
                            </dl>
                        </fieldset>
                        </div>
        <#if (org.organizationCode)??> 
                 <#assign createInfo=org/>
                 <#include "/common/createInfo.html">
                </#if>
                    </div>
                    <div>
                            <div class="pageFormContent">
                            <div id="bar" class="pBar">
                                <ul class="toolBar">
                                    <input id="userid"  type="hidden" name="userLookup.id" type="text" />
                                    <input id="username"  type="hidden" name="userLookup.name" type="text" />
                                    <li><a class="add" width="640" height="500" href="${rc.getContextPath()}/manage/org/selectUser?navTabId=${navTabId!''}" lookupGroup="userLookup" callback="user_callback"><span><@label key="add.B">新增</@label></span>
                                    </a>
                                    </li>
                                    <li><a href="javascript:" class="delete" onclick="userdel()"><span><@label key="delete.B">删除</@label></span> </a>
                                    </li>
                                </ul>
                            </div>
                            <table class="table border" width="100%" layoutH="400">
                                <thead>
                                    <tr>
                                        <th width="20"><input type="checkbox" group="ids" class="checkboxCtrl">
                                        </th>
                                        <th width="100"><@label key="userCode.C">用户编号</@label></th>
                                        <th width="100"><@label key="userText.C">用户名称</@label></th>
                                    </tr>
                                </thead>
                                <tbody id="usertbody">
                                    <#if users??><#if (users?size>0)> <#list users as user>
                                    <tr id="user_${user.userCode!''}" target="user_code" rel="${user.userCode!''}">
                                        <td width="20"><input type="checkbox" name="ids" class="checkboxCtrl" value="${user.userCode!''}">
                                        </td>
                                        <td width="100">${user.userCode!''}</td>
                                        <td width="100">${user.userText!''}</td>
                                    </tr>
                                    </#list> </#if> </#if>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                    <div class="tabsFooter" style="height: 40px;">
                                <div class="tabsFooterContent" style="height: 40px;padding-left: 50px;">
                        <div class="buttonActive">
                            <div class="buttonContent">
                                <button type="submit" onclick="c()"><@label key="save.B">保存</@label></button>
                            </div>
                        </div>
                        <div class="buttonActiveGrey" style="margin-left: 10px;">
                            <div class="buttonContent">
                                <button  type="button" onclick="cancel()"><@label key="cancel.B">取消</@label></button>
                            </div>
                        </div>
                </div>
                                </div>
                            </div>
        

        </div>
                
    </div>
        
</form>

     <script type="text/javascript">
     function cancel() {
        $("#orgDetail",navTab.getCurrentPanel()).html("");
     }
     
        function user_callback() {
            var id = $("#userid").val();
            var name = $("#username").val();
            var idArr = new Array();
            var nameArr = new Array();
            idArr = id.split(',');
            nameArr = name.split(',');
            var ht = "";
            for ( var i = 0; i < idArr.length; i++) {
                var userid = idArr[i];
                var username = nameArr[i];
                var my_element = $("#user_" + userid);
                if (my_element.length == 0) {
                    ht += "<tr id='user_"+userid+"'target='user_code' rel='"+userid+"'><td width='11'><input  name='ids' value='"+userid+"' type='checkbox'></td><td width='100'>"
                            + userid
                            + "</td><td width='100'>"
                            + username
                            + "</td></tr>";
                }

            }
            $("#usertbody").append(ht);

        }
        
        function userdel() {
            var count=0;
            $('input[name="ids"]:checked').each(function(i, e) {
                count++;
            });
            if(count==0)
                {
                alertMsg.warn('<@label key="selectUser.M">请勾选用户！</@label>')
                }
            else
                {
            alertMsg.confirm("<@label key="delUser.M">确定要删除选中的用户吗？</@label>", {
                okCall : function() {
                    $('input[name="ids"]:checked').each(function(i, e) {
                        $("#user_" + e.value).remove();
                    });
                }
            });
                }
        }
        
        function c() {
            var user = "";
            var usertable = $("#usertbody");
            usertable.find("tr").each(function(i, n) {
                var obj = $(n);
                user += obj.attr("id").replace("user_", "") + ",";
            });
            
            if (user.length > 1) {
                user = user.substring(0, user.length - 1);
            }
            $("#user").val(user);

        }
     </script>